package cn.keepme.ep.util;

import org.jeecgframework.core.util.PasswordUtil;

/**
 * 签名认证 加密/解密
 * @author cp
 *
 */
public class ParamsSign {
	
	/** 加密种子,盐值  **/
	public static final String seed = "keepme";
	
//	public static final String seed = "6Z781KolCXb2eqE2Tw2z2650gr9u63po18h5vnx2P97z46y404X325Xh6KmV5E2d90Bk89x1p5aJKW32y5X13u6644Kx9vJRcNG7x1O85S1TU1RHR5V7yL9z6U3f179q";
	
	/**
	 * 加密，生成 用户唯一标示
	 * @param payLaunch
	 * @param user
	 * @return
	 */
	public static String encode(String plaintext, String password) {
		String ciphertext = "";
//		org.jeecgframework.core.util.LogUtil.info("明文:" + plaintext);
//		org.jeecgframework.core.util.LogUtil.info("密码:" + password);

		try {
			byte[] salt = PasswordUtil.getStaticSalt();
			ciphertext = PasswordUtil.encrypt(plaintext, password, salt);
//			org.jeecgframework.core.util.LogUtil.info("密文:" + ciphertext);
//			String plaintext1 = PasswordUtil.decrypt(ciphertext, password, salt);
//			org.jeecgframework.core.util.LogUtil.info("明文:" + plaintext1);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return ciphertext;
	}
	
	/**
	 * 解密，获取 用户唯一标示
	 * @param payLaunch
	 * @param user
	 * @return
	 */
	public static String decode(String ciphertext, String password){
		String plaintext1 = "";
		try {
			byte[] salt = PasswordUtil.getStaticSalt();
			plaintext1 = PasswordUtil.decrypt(ciphertext, password, salt);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return plaintext1;
	}

	public static void main(String[] args) {
//		String id = "2";
//		String p = "zhangsan@163.com";
//		String s = encode(p,id);
//		System.out.println(s);
//		String s2 = decode(s,id);
//		System.out.println(s2);
		
		System.out.println(PublicParams.questionType.get("duoxuan"));
		
	}
	
}
